<template>
	<div id="index">


	</div>
</template>

<script>
	import homeapi from '@/api/api.js'
    import until  from '@/api/until';
	export default {
        name: 'code',
		data(){
			return {
				token:"",
				loginType:"",
			}
		},
		mounted(){
			let token=until.getCookie("token");
			this.loginType=until.getCookie("loginType")
			if(this.loginType){

			}
			else{
				this.loginType=2;
			}
			if(token){
				this.getUserInfo(1);
				
			}
			else{
				token=until.getParameter("token")
				if(token){
					
					until.setCookie("token",token);
					
				}
				else{
					this.$router.push("/login/loginnew")
				
				}
				
		
			}
		},
        components: {
            
        },
		methods:{
			async getUserInfo(){
			
				let data=await homeapi.getUserinfo();
				if(data.code==200){
					this.$root.userInfo=data.result
                    if(data.result.type==2){
                        this.$router.push("/user/index")
                        
                    }
                    else{
                    
                        this.$router.push("/company/index")
                    }

				}
				
			}
		}
    }
</script>

<style lang="less">

</style>
